<template>
    <el-dialog v-model="dialogTableVisible" title="直推信息" width="90%">
        <p>社区人数：{{ list.length }}</p>
        <el-table ref="multipleTable" :data="list" v-loading="loading">
            <el-table-column prop="Id" width="60" label="#"> </el-table-column>
            <el-table-column prop="Address" label="用户地址" width="200">
            </el-table-column>
            <el-table-column prop="Upline" label="上级地址" width="200">
            </el-table-column>
            <el-table-column prop="USDT" label="USDT" width="110"> </el-table-column>
            <el-table-column prop="TotalInvest" label="入金" width="110"> </el-table-column>
            <el-table-column prop="UserLevel" label="用户等级" width="110"></el-table-column>
            <el-table-column prop="InvitationCode" label="邀请码" width="110"></el-table-column>
            <el-table-column prop="DirectCount" label="有效直推" width="110"></el-table-column>
            <el-table-column prop="DownlineCount" label="社区成员" width="110">
            </el-table-column>
            <el-table-column prop="DownlineInvest" label="社区入金" width="110">
            </el-table-column>
            <el-table-column prop="DownlineLevel" label="社区等级" width="110">
            </el-table-column>
            <el-table-column prop="CreatedAt" label="注册时间" min-width="160">
            </el-table-column>
        </el-table>
        <div class="right">
            <el-pagination background layout="total, sizes, prev, pager, next, jumper" :page-size="formData.pageSize"
                :total="formData.total" @size-change="handleSizeChange" @current-change="handleCurrentChange">
            </el-pagination>
        </div>
    </el-dialog>
</template>
<script setup>
import { reactive, ref, defineExpose } from 'vue'
import { getDirectList } from "@/api";
const dialogTableVisible = ref(false)
const formData = reactive({
    pageNum: 0,
    pageSize: 10,
    total: 0,
    address: ""
})
const loading = ref(false)
const list = ref([])
const onSubmit = async () => {
    loading.value = true
    try {
        const res = await getDirectList(formData);
        console.log(res)
        list.value = res.data.data.DirectList
        formData.total = res.data.data.Total;
        SumUSDT.value = res.data.data.SumUSDT
    } catch (error) { }
    loading.value = false
}
const handleSizeChange = (val) => {
    formData.pageSize = val;
    formData.pageNum = 0;
    onSubmit();
}
const handleCurrentChange = (val) => {
    formData.pageNum = val - 1;
    onSubmit();
}

const show = (item) => {
    dialogTableVisible.value = true;
    formData.address = item.Address;
    onSubmit();
}
defineExpose({
    show,
})
</script>
<style lang="scss" scoped>
.right {
    overflow: auto;
}

.el-pagination {
    padding: 15px;
    float: right;
}
</style>